const http = require('http');
const fs = require('fs');
const zlib = require('zlib');
const gzip = zlib.createGzip();

http.createServer((req,res)=>{
    console.log(req);
    const readStream = fs.createReadStream('./java学习笔记.md');
    res.writeHead(200,{'Content-Type':'text/markdown;charset=utf-8'});
    readStream.pipe(gzip).pipe(res);
    
    // readStream.on('data',(chunk)=>{
    //     res.write(chunk);
    // })

    // readStream.on('end',()=>{
    //     res.end();
    // })
}).listen(7000,()=>{
    console.log('server start!');
})